#include <limits.h>  // INT_MIN,INT_MAX
#include <math.h>    // abs,pow

#include <algorithm>      // sort
#include <iostream>       // cout,cin
#include <numeric>        // accumulate
#include <string>         // string
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <vector>         // vector

using namespace std;

// 如果x是2的幂则返回True，否则返回False
bool IsPowerOf2(int x) { return (x & (x - 1)) == 0; }

class Solution {
   public:
    bool checkInclusion(string s1, string s2) {
        int size1 = s1.size();
        int size2 = s2.size();

        if (size1 > size2) {
            return false;
        }

        vector<int> count1(26, 0);
        vector<int> count2(26, 0);

        for (int i = 0; i < size1; i++) {
            count1[s1[i] - 97] += 1;
            count2[s2[i] - 97] += 1;
        }

        if (count1 == count2) {
            return true;
        }

        for (int i = size1; i < size2; i++) {
            count2[s2[i - size1] - 97] -= 1;
            count2[s2[i] - 97] += 1;
            if (count1 == count2) {
                return true;
            }
        }

        return false;
    }
};

int main() {
    Solution solution;
    return 0;
}